// Suggestion form
FlyTalk.views.MapView = Ext.extend(Ext.form.FormPanel, {
	title: 'Map',
	scroll: false,
	
    initComponent: function () {
		// back button on toolbar
		this.backButton = new Ext.Button({
			text: 'Back',
			ui: 'back',
			handler: this.backButtonTap,
			scope: this
		});
		
		// save button on toolbar
		this.saveButton = new Ext.Button({
			text: 'Send',
			ui: 'action',
			handler: this.saveButtonTap,
			scope: this
		});
		
		// top tool bar
		this.composeToolbar = new Ext.Toolbar({
			title: 'Suggestion',
			
			items:[
				this.backButton,
				{ xtype: 'spacer' },
				this.saveButton,
			]
			
		});

        this.dockedItems = [this.composeToolbar];

        FlyTalk.views.MapView.superclass.initComponent.call(this);
    },	

    backButtonTap: function () {
		this.reset();
//        Ext.dispatch({
//            controller: FlyTalk.controllers.ftController,
//            action: 'openHome'
//        });
		var next = FlyTalk.views.TalkView.tweetToolbar.title; // see which page talk is on right now
		Ext.dispatch({
            controller: FlyTalk.controllers.ftController,
            action: 'openNext',
            next: next,
        });
    },
    
    saveButtonTap: function () {
		 var message = Ext.getCmp('message').getValue();
		 var user = Ext.getCmp('curUser').getValue();
		 this.reset();
		 Ext.dispatch({
	            controller: FlyTalk.controllers.dbController,
	            action: 'saveSuggestion',
	            uid: user,
	            comment: message,
			});
    },
   
	
	scroll: true,
	items: [	        
	{ // select a user (researcher mode only!) - THIS FIELD HAS TO BE THE FIRST. DO NOT CHANGE!
	    xtype: 'selectfield',
	    name: 'user',
	    id: 'curUser',
	    label: 'select user',
	    labelWidth: 300,
	    labelAlign: 'top',
	    options: [
	    	 {text: 'HappyTraveler',  value: '3'},
	    	 {text: 'Jessica', value: '4'},
	    	 {text: 'TAP Airline',  value: '1'},
	    	 {text: 'Airport',  value: '2'},
	    ]
	},{html: ''},	
	{html: 'Give other travelers an ideas on how they can pass time at the airport.'},
	{  // textarea for msg
        xtype: 'textareafield',
		id:'message',
        name: 'title',
        label: 'HappyTraveler suggests:',
        labelWidth: 300,
		labelAlign: 'top',
        required: true
    },
	{html: 'Where to do it:'},
	
		{
			xtype:'button',
			text: 'Current location',
			style: 'margin: .5em'
	
	
		},{
			xtype:'button',
			text: 'Find on map',
			style: 'margin: .5em'
	
		},
	
	{html: 'Add a photo:'},
	{
		xtype:'button',
		text: 'Camera',
		style: 'margin: .5em'
	
	},{
		xtype:'button',
		text: 'Upload',
		style: 'margin: .5em'
	
	},
/*
	{
		xtype:'button',
		text: 'Submit',
		style: 'margin: 1em .5em .5em .5em'
	}*/
	]
});

